/**
 *    Copyright (C) 2009  Victor Smirnov <aist11@gmail.com>
 *
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License along
 *    with this program; if not, write to the Free Software Foundation, Inc.,
 *    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 *    See LICENSE.exceptions in the root folder of this project for possible
 *    exceptions
 *
 */

#ifndef _CUBEFS_CORE_MODELS_BLOB_MAP_FACTORY_HPP
#define _CUBEFS_CORE_MODELS_BLOB_MAP_FACTORY_HPP

#include <cubefs/core/container/container.hpp>

#include <cubefs/core/dynvector/dynvector.hpp>

#include <cubefs/core/models/blob_map/iterator/model_api.hpp>
#include <cubefs/core/models/blob_map/iterator/tools.hpp>

#include <cubefs/core/models/blob_map/pages/data_page.hpp>

#include <cubefs/core/models/blob_map/model/api.hpp>
#include <cubefs/core/models/blob_map/model/model_api.hpp>
#include <cubefs/core/models/blob_map/names.hpp>

#include <cubefs/core/models/blob_map/tools.hpp>

namespace cubefs { namespace ctr {

using namespace cubefs::ctr;

CUBEFS_TYPE_FACTORY_BEGIN(RootProfile, cubefs::BlobMap)

    struct ModelTypes: public DynVectorTypes<Profile, cubefs::BlobMap> {
        typedef DynVectorTypes<Profile, cubefs::BlobMap> 						Base;

        typedef typename AppendTool<
                    typename Base::ModelPartsList,
                    typename TypeListTool<
                        cubefs::models::blob_map::ApiName,
                        cubefs::models::blob_map::ModelApiName,

                        cubefs::models::model::ApiName,
                        cubefs::models::model::ModelApiName
                    >::List
        >::Result                                                               ModelPartsList;

        typedef typename AppendTool<
                    typename Base::IteratorPartsList,
                    typename TypeListTool<
                        cubefs::models::blob_map::IteratorToolsName,
                        cubefs::models::blob_map::IteratorModelAPIName
                    >::List
        >::Result                                                               IteratorPartsList;

//        typedef typename TypeListTool<
//                    cubefs::models::idx_map::IndexPagePrefixName<Base::Indexes>
//        >::List                                                                 BasePagePartsList;

        typedef cubefs::api::BlobMapImpl                                        ModelInterfaceName;
        typedef cubefs::api::BlobMapIteratorImpl                                IteratorInterfaceName;


        typedef cubefs::models::blob_map::CountData                             CountDataType;
        typedef cubefs::models::blob_map::BufferContentDescriptor<CountDataType>BufferContentDescriptorType;
        


        template <Int Size>
        struct DataBlockTypeFactory {
            typedef cubefs::blob_map::DynVectorData<Size>                       Type;
        };

    };

    typedef cubefs::dynvector::DynVector<ModelTypes>                            BTreeType;
    
public:
    typedef typename TypeLocator<Profile, BTreeType>::Type                      Type;

CUBEFS_TYPE_FACTORY_END

}}

#endif 
